/*
 * KKScene.h
 *
 *  Created on: 2013-9-15
 *      Author: wanghua
 */

#ifndef KKSCENE_H_
#define KKSCENE_H_

#include "kaka_common.h"
#include "KKSprite.h"
#include "KKStoryboard.h"
#include "KKLayer.h"

USING_NS_CC;

typedef KKDictionary<std::string, KKStoryboard*> KKStoryboardDictionary;

typedef enum {
	NONE,
	FADE_IN,
	FLIP_LEFT,
	FLIP_RIGHT,
	FLIP_UP,
	FLIP_DOWN,
	SHRINK_GROW,
	MOVE_IN_L,
	MOVE_IN_R,
	MOVE_IN_T,
	MOVE_IN_B,
	SLIDE_L,
	SLIDE_R,
	SLIDE_T,
	SLIDE_B,
	CROSS,
	RADIAL_CCW,
	RADIAL_CW,
	PAGE_FORWARD,
	PAGE_BACK
} KKSceneTransitionMode;

typedef KKDictionary<std::string, KKSceneTransitionMode*> KKSceneTransitionModeDictionary;

class KKSceneUpdateListener {
public:
	virtual void onUpdate(ccTime time)=0;
};

class KKScene: public CCScene, public KKNode {
private:

	;CC_SYNTHESIZE_READONLY(string,m_path,Path)
	;CC_SYNTHESIZE(KKSceneUpdateListener*,m_sceneUpdateListener,SceneUpdateListener)
	;CC_SYNTHESIZE_READONLY(b2World*,m_world,World)
	;CC_SYNTHESIZE(bool,m_push,IsPush)

	GLESDebugDraw* m_debugDraw;
	KKStoryboardDictionary* m_storyboards;

public:
	static float PTM_RATIO;

public:
	KKScene(const char* name, const char* path);
	virtual ~KKScene();

	static KKScene* sceneWithFile(const char* sceneName, const char* sceneFile);

	void resetNode(bool reload = false, bool stopAction = false);

	void loadNode();

	void reloadScene();

	bool loadScene();

	void unloadScene();

	bool loadScene(const char* sceneFile);

	void loadStoryboards(const char* storyboardFile);

	KKStoryboard* storyboardNamed(string storyboardName);

	void update(ccTime dt);

	virtual void onEnter();

	virtual void onExit();

	virtual void setIsVisible(bool isVisible) {
		CCScene::setVisible(isVisible);

	}
	;
	virtual bool getIsVisible() {
		return CCScene::isVisible();
	}
	;

	CCPoint getLocalTouchPoint(const CCPoint& point) {

		return ccp(point.x, point.y);
	}

	virtual void visit();

	virtual void initWorld();

	virtual void destoryWorld();

	b2Body* createBody(KKNode* sprite, int16 category = 1, int16 mask = 1,
			b2Shape* shape = NULL, string nodeVertexesName = "");

	void destroyBody(KKNode* sprite);

	b2Fixture* createFixture(KKNode* sprite, KKNodeVertexes* nodeVertexes,
			int16 category = 1, int16 mask = 1);

	b2Fixture* createFixture(KKNode* sprite, b2Shape* shape,
			int16 category = 1, int16 mask = 1);

};

#endif /* KKSCENE_H_ */
